﻿#include "mainwindow.h"
#include "logindlg.h"
#include "modechoose.h"
#include "simpletest.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    LoginDlg dlg;
    ModeChoose mc;
    //将三个窗口命名以便进行界面设置
    w.setObjectName("w");
    dlg.setObjectName("dlg");
    mc.setObjectName("mc");
    dlg.show();
    //相关信号与槽函数的连接
    QObject::connect(&dlg,SIGNAL(modeChoose()),&mc,SLOT(show()));
    QObject::connect(&dlg,SIGNAL(quitGame()),&a,SLOT(quit()));
    QObject::connect(&mc,SIGNAL(returnDlg()),&dlg,SLOT(show()));
    QObject::connect(&mc,SIGNAL(singleMode()),&w,SLOT(singleModeStart()));
    QObject::connect(&mc,SIGNAL(multiMode()),&w,SLOT(multiModeStart()));
    QObject::connect(&dlg,SIGNAL(loadFile()),&w,SLOT(loadGame()));
    QObject::connect(&w,SIGNAL(quitGame()),&a,SLOT(quit()));
    QObject::connect(&w,SIGNAL(returnLogindlg()),&w,SLOT(restart()));
    QObject::connect(&w,SIGNAL(loadFileFail()),&dlg,SLOT(show()));
    //测试
    SimpleTest *test = new SimpleTest();
    QTest::qExec(test);
    delete test;
    return a.exec();
}
